package duhosdebuggolok;

import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;

public class AnthillPainter implements Painter{
	
	private static BufferedImage anthillImage0 = null;
	private static BufferedImage anthillImage1 = null;
	private static BufferedImage anthillImage2 = null;
	private Anthill anthill;
	
	public AnthillPainter(Anthill ah) {
		anthill = ah;
		if(anthillImage0 == null)
			loadImage();
	}
	
	private static void loadImage() {
			try {
				anthillImage0 = ImageIO.read(new File(System.getProperty("user.dir")+"\\resources\\hangyaboly.png"));
				anthillImage1 = ImageIO.read(new File(System.getProperty("user.dir")+"\\resources\\hangyaboly3.png"));
				anthillImage2 = ImageIO.read(new File(System.getProperty("user.dir")+"\\resources\\hangyaboly5.png"));
			} catch (IOException e) {
				e.printStackTrace();
			}
	}
	
	public boolean paint(Graphics2D g){ 
		Point coord = anthill.getCoord();
		int radius = anthill.getRadius();
		//double scale = 1;
		//sAffineTransform affineTransform = new AffineTransform();
		Point c = GamePanel.calculate(coord);
		//affineTransform.translate((c.x-30*radius), (c.y-25*radius));
		//affineTransform.scale(2*radius+scale, 2*radius+scale);
		//affineTransform.rotate(Math.toRadians(45), 5, 5);
		switch (radius) {
		case 0: g.drawImage(anthillImage0, c.x, c.y+3, null);
				break;
		case 1: g.drawImage(anthillImage1, c.x-30, c.y-23, null);
				break;
		case 2: g.drawImage(anthillImage2, c.x-60, c.y-50, null);
				break;
		}
		return true;
	}
}
